import imageio
import os

def create_gif(image_list, gif_name):
 
    frames = []
    for image_name in image_list:
        frames.append(imageio.imread(image_name))
    # Save them as frames into a gif 
    imageio.mimsave(gif_name, frames, 'GIF', duration = 0.1)
 
    return
 
def main():
    image_list = []
    testdir = '../img/'

    for name in os.listdir(testdir): 
        image_list.append(os.path.join(testdir, name))

    image_list.sort()

    gif_name = 'created_gif.gif'
    create_gif(image_list, gif_name)


if __name__ == "__main__":
    main()


# --------------------- 
# 作者：PHILOS_THU 
# 来源：CSDN 
# 原文：https://blog.csdn.net/guduruyu/article/details/77540445 
# 版权声明：本文为博主原创文章，转载请附上博文链接！